import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/admin/acl/index/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/admin/acl/index/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/admin/acl/index/logout',
    method: 'post'
  })
}
// 获取用户管理的分页列表
export const reqUserList = (page, limit, username) => request({
  method: 'get',
  url: `/admin/acl/user/${page}/${limit}`,
  params: {
    username
  }
})
// 通过用户获取角色列表
export const reqRoleByUser = (userId) => request({
  method: 'get',
  url: `/admin/acl/user/toAssign/${userId}`
})
// 根据用户分配角色
export const byUserRole = (userId, roleId) => request({
  method: 'post',
  url: '/admin/acl/user/doAssign',
  params: {
    userId,
    roleId
  }
})
// 新增管理用户
export const reqAddUser = (data) => request({
  method: 'post',
  url: '/admin/acl/user/save',
  data
})
// 修改用户的名称
export const reqEditUserNmae = (data) => request({
  method: 'put',
  url: '/admin/acl/user/update',
  data
})
// 删除某个用户
export const deleteUser = (id) => request({
  method: 'delete',
  url: `/admin/acl/user/remove/${id}`
})
// 批量删除
export const deleteUsersd = (data) => request({
  method: 'delete',
  url: '/admin/acl/user/batchRemove',
  data
})
// 获取角色分页列表
export const reqroleLList = (page, limit, roleName) => request({
  method: 'get',
  url: `/admin/acl/role/${page}/${limit}`,
  params: {
    roleName
  }
})
// 根据角色获取菜单
export const reqGetMenuById = (roleId) => request({
  method: 'get',
  url: `/admin/acl/permission/toAssign/${roleId}`
})
// 给角色分配权限
export const reqassignuserRole = (roleId, permissionId) => request({
  method: 'post',
  url: `/admin/acl/permission/doAssign`,
  params: {
    roleId,
    permissionId
  }
})
// 更新角色名称
export const reqUpdateRoleName = (data) => request({
  method: 'PUT',
  url: '/admin/acl/role/update',
  data
})
// 删除角色
export const reqDeteleUser = (id) => request({
  method: 'delete',
  url: `/admin/acl/role/remove/${id}`
})
// 新增角色
export const reqAddUserrole = (data) => request({
  method: 'post',
  url: '/admin/acl/role/save',
  data

})
// 批量删除角色
export const dateleUsers = (data) => request({
  method: 'delete',
  url: '/admin/acl/role/batchRemove',
  data
})
